<!DOCTYPE html>
<html lang="en" xmlns:v-on="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="app">
    {{message}}
    {{num}}
    <button v-on:click="add">增加</button>
    <button v-on:click="sub">减少</button>
</div>
</body>
<script src="node_modules/vue/dist/vue.js" ></script>
<script>
    var vm = new Vue({
        el:"#app", // el即element，该vue实例要渲染的页面元素
        data:{ // 渲染页面需要的数据
            num:0,
            message:'hello'
        },
        methods:{
            add:function () {
                this.num++;
                this.message=this.num;
                console.log(this);
                console.log(vm);
            },
            sub:function () {
                this.num--;
            }
            },
        //生命周期：vue创建之后，渲染之前执行
        created:function () {
            this.num=100;
        },
        //vue渲染之后执行
        mounted()  {
            this.num=1000;
        }
    });

</script>
</html>